package com.zhengxyou.jetpackdemo.dataBinding;

import android.text.TextUtils;
import android.util.Log;
import android.widget.Button;
import android.widget.ImageView;

import androidx.annotation.DrawableRes;
import androidx.databinding.BindingAdapter;

public class BindingAdapterTest {
    //覆盖 Android 原先的控件属性
    @BindingAdapter("android:text")
    public static void setText(Button view, String text) {
        view.setText(text + "-button");
    }

    @BindingAdapter("url")
    public static void loadImage(ImageView view, String url) {
        if (!TextUtils.isEmpty(url)) {
            Log.e("BindingAdapterTest", url);
        }
    }

    @BindingAdapter("urlId")
    public static void loadImage(ImageView view, @DrawableRes int resId) {
        view.setImageResource(resId);
    }
//    @BindingAdapter("time")
//    public static void setTime(TextView view, Time newValue){
//        if(view.tiem)
//    }
}
